#include <iostream>
#include <vector>
#include <stack>
#include <string>
using namespace std;
class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        stack<int> st;
        for (auto e : tokens)
        {
            if (e != "+" && e != "-" && e != "*" && e != "/")
            {
                st.push(stoi(e));
            }
            else
            {
                int a = st.top();
                st.pop();
                int b = st.top();
                st.pop();
                int ans = 0;
                if (e == "+") ans = b + a;
                else if (e == "-") ans = b - a;
                else if (e == "*") ans = b * a;
                else ans = b / a;
                st.push(ans);
            }
        }
        return st.top();
    }
};

int main()
{
    vector<string> tokens = { "2","1","+","3","*" };
    int ans=Solution().evalRPN(tokens);
    cout << ans << endl;
    return 0;
}